import meteAPI from "@/api/system/meterReader";
import type { ISelectConfig } from "@/components/TableSelect/index.vue";

// 水表
const selectConfig: ISelectConfig = {
  pk: "id",
  width: "70%",
  placeholder: "请选择",
  formItems: [
    {
      type: "input",
      label: "姓名",
      prop: "s_name",
      attrs: {
        placeholder: "请输入姓名",
        clearable: true,
        style: {
          width: "120px",
        },
      },
    },
    {
      type: "input",
      label: "手机号",
      prop: "s_tel",
      attrs: {
        placeholder: "请输入手机号",
        clearable: true,
        style: {
          width: "160px",
        },
      },
    },
  ],
  indexAction: function (params) {
    if ("createAt" in params) {
      const createAt = params.createAt as string[];
      if (createAt?.length > 1) {
        params.startTime = createAt[0];
        params.endTime = createAt[1];
      }
      delete params.createAt;
    }
    return meteAPI.getPage(params);
  },
  tableColumns: [
    { type: "selection", width: 50, align: "center" },
    { label: "姓名", align: "center", prop: "name", width: 180 },
    { label: "手机号", align: "center", prop: "tel" },
  ],
};

export default selectConfig;
